// pages/appointment_result/appointment_result.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tmplIds: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  getMsgList(){
    const that = this;
    wx.request({
      url: 'https://info.amagich.com/wx/submsg-list',
      data: {

      },
      method: "post",
      success: function (res) {
          const {data} = res.data;
          console.log(data)
        that.setData({
            tmplIds: data
          })

        }
      })
  },
  submsg() {
    const that = this;
    const  tmplIds = that.data.tmplIds.map(msg => msg.template_id);
    console.log(tmplIds)
    wx.requestSubscribeMessage({
      tmplIds,
      success (res2) {
        console.log(res2)
      },
      fail (res2) {
        console.log(res2)
      },
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getMsgList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

})